/**
 * Created by xukj on 2018/6/6.
 */

import React from 'react';
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux';
import * as actionCreator from '../../actions/HomeAction';
import Home from './Home';

class HomeContainer extends React.PureComponent {
  static navigationOptions = ({navigation}) => {
    const { params = {title: ''}} = navigation.state;
    return {
      headerTitle: params.title ? params.title : '首页',
    };
  };
  //
  // componentDidMount() {
  //   this.props.navigation.setParams({
  //     mainPageTo: this.props.mainPageTo,
  //   });
  // }

  render() {
    console.log('home render');
    return (
      <Home {...this.props} />
    );
  }
}

const mapStateToProps = (state) => {
  return {
    mainPageTo: state.HomeReducer.mainPageTo,
  }
};

const mapDispatchToProps = (dispatch) => {
  const mainPageToAction = bindActionCreators(actionCreator, dispatch);
  return {
    mainPageToAction,
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(HomeContainer);